﻿using AnesSystem.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace AnesSystem.Controls
{
    /// <summary>
    /// IEDropDownListCtrl.xaml 的交互逻辑
    /// </summary>
    public partial class IEDropDownListCtrl : BaseVitalCellCtrl
    {
        public IEDropDownListCtrl()
        {
            InitializeComponent();
            _cmb.FontSize = RealTimeSignShowUtil.CELLFONTSIZE-2;
            _cmb.Height = RealTimeSignShowUtil.CELLHEIGHT - 3;
            _cmb.Width = RealTimeSignShowUtil.CELLWIDTH - 3;
            this._cmb.Background = this.Background;
            _cmb.GotFocus += _cmb_GotFocus;
            _cmb.LostFocus += _cmb_LostFocus;
            _cmb._txtName.TextChanged += _txtName_TextChanged;
            InitialData();
        }
        private void _txtName_TextChanged(object sender, TextChangedEventArgs e)
        {
            IngValue = (sender as TextBox).Text;
        }

        private void _cmb_LostFocus(object sender, RoutedEventArgs e)
        {
            this._cmb.Background = this.Background;
        }

        private void _cmb_GotFocus(object sender, RoutedEventArgs e)
        {
            RealTimeSignLeftCtrlViewModel.Instance.SelectedIndex = RowIndex - 1;
            this._cmb.Background = Brushes.White;
        }
        public void InitialData()
        {
            List<CommonComboboxItemModel> list = new List<CommonComboboxItemModel>()
            {
                new CommonComboboxItemModel()
                {
                    Display="",
                    Behind=""
                },
                new CommonComboboxItemModel()
                {
                    Display="1:2.5",
                    Behind="1:2.5"
                },
                new CommonComboboxItemModel()
                {
                    Display="1:2",
                    Behind="1:2"
                },
                new CommonComboboxItemModel()
                {
                    Display="1:1.5",
                    Behind="1:1.5"
                }
            };
            _cmb.ItemsSource = list;
        }
        public override void SetFocus()
        {
            _cmb._txtName._txt.Focus();
            _cmb._txtName._txt.SelectAll();
        }
    }
}
